package lang;

class Account {
    private long id;
    private double balance;
    public Account(long id, double balance) {
        this.id = id;
        this.balance = balance;
    }


    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }


    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }




    public double getBalnace() {
        return balance;
    }

    public synchronized double takeMoney(double money) {
        if (balance >= money) {
            balance -= money;
            return money;
        }
        money = balance;
        balance = 0;
        return money;
    }

    public synchronized void save(double money) {
        if (money < 0) {
            return;
        }
        balance += money;
    }
}
